<style lang="less">
@import "./lineActivityDetail.less";
</style>
<template>
    <div class="search" style="background-color:white" id="pop">
        <template>
          <Form ref="lineDetailForm" :model="lineDetailForm" :label-width="110" :rules="lineDetailFormValidate">
             <Tabs type="card">
                <TabPane label="基础信息" style="border-left: 1px solid #dddee1;">
                  <Form-item label="线路活动标题:" prop="title" style="padding-top:16px;">
                    <Input type="text" v-model="lineDetailForm.title" clearable placeholder="请输入活动标题" style="width: 500px"/>
                  </Form-item>
                  <Form-item label="线路活动卖点:" prop="sellPoint">
                    <Input type="text" v-model="lineDetailForm.sellPoint" clearable placeholder="请输入活动卖点" style="width: 500px"/>
                  </Form-item>
                  <Form-item label="线路活动天数:">
                    <div>
                      <Input type="text" v-model="lineDetailForm.lineDay" clearable style="width: 80px"/>
                      <span style="width:40px;display:inline-block;text-align: center;">天</span>
                      <Input type="text" v-model="lineDetailForm.lineNight" clearable style="width: 80px"/>
                      <span style="width:40px;display:inline-block;text-align: center;">晚</span>
                    </div>
                  </Form-item>
                  <!-- <Form-item label="活动特色:" prop="title">
                    <Input type="text" v-model="lineDetailForm.title" clearable placeholder="请输入昵称" style="width: 800px"/>
                  </Form-item> -->
                  <Form-item label="成形人数:" prop="totalNum">
                    <Input type="text" v-model="lineDetailForm.totalNum" clearable style="width: 80px"/>
                  </Form-item>
                  <Form-item label="门市价:" prop="storePrice">
                    <!-- <InputNumber v-model="lineDetailForm.storePrice" clearable style="width: 80px"/> -->
                    <Input type="text" v-model="lineDetailForm.storePrice" clearable style="width: 80px"/>
                  </Form-item>
                  <Form-item label="最低价:" prop="price">
                    <!-- <InputNumber v-model="lineDetailForm.price" clearable style="width: 80px"/> -->
                    <Input type="text" v-model="lineDetailForm.price" clearable style="width: 80px"/>
                  </Form-item>
                  <Form-item label="活动开始时间:" prop="beginDate">
                    <!-- <DatePicker type="datetime" v-model="lineDetailForm.beginDate" placeholder="请选择活动开始时间" style="width: 200px"></DatePicker> -->
                    <DatePicker type="date" v-model="lineDetailForm.beginDate" placeholder="请选择活动开始时间" style="width: 200px"></DatePicker>
                  </Form-item>
                  <Form-item label="活动结束时间:" prop="endDate">
                    <!-- <DatePicker type="datetime" v-model="lineDetailForm.endDate" placeholder="请选择活动结束时间" style="width: 200px"></DatePicker> -->
                    <DatePicker type="date" v-model="lineDetailForm.endDate" placeholder="请选择活动结束时间" style="width: 200px"></DatePicker>
                  </Form-item>
                  <Form-item label="报名开始时间:" prop="signStartDate">
                    <!-- <DatePicker type="datetime" v-model="lineDetailForm.signStartDate" placeholder="请选择报名开始时间" style="width: 200px"></DatePicker> -->
                    <DatePicker type="date" v-model="lineDetailForm.signStartDate" placeholder="请选择报名开始时间" style="width: 200px"></DatePicker>
                  </Form-item>
                  <Form-item label="报名结束时间:" prop="signEndDate">
                    <!-- <DatePicker type="datetime" v-model="lineDetailForm.signEndDate" placeholder="请选择报名结束时间" style="width: 200px"></DatePicker> -->
                    <DatePicker type="date" v-model="lineDetailForm.signEndDate" placeholder="请选择报名结束时间" style="width: 200px"></DatePicker>
                  </Form-item>
                  
                  <Form-item label="出团时间:" prop="lineDate">
                    <!-- <DatePicker type="date" v-model="lineDetailForm.lineDate" format="yyyy-MM-dd" placeholder="请选择出团时间" style="width: 200px"></DatePicker> -->
                    <DatePicker type="datetime" v-model="lineDetailForm.lineDate" placeholder="请选择出团时间" style="width: 200px"></DatePicker>
                  </Form-item>
                  <!-- <Form-item label="集合地址:" prop="title">
                    <Input type="text" v-model="searchForm.title" clearable placeholder="请输入昵称" style="width: 800px"/>
                  </Form-item>
                  <Form-item label="集合标识:" prop="title">
                  </Form-item> -->
                  <Form-item label="提前预定:" prop="lineBefore">
                    <div>
                      <span style="width:60px;display:inline-block;text-align: center;">建议提前</span>
                      <Input type="text" v-model="lineDetailForm.lineBefore" clearable style="width: 80px"/>
                      <span style="width:46px;display:inline-block;text-align: center;">天报名</span>
                      <Checkbox v-model="single">少于提前天数，则禁止预订</Checkbox>
                    </div>
                  </Form-item>
                  <!-- <div style="border:1px solid red;width:100%;"></div> -->
                  <hr style="border-bottom:1px solid #dddee1; height:1px;">
                  <Form-item label="出发城市:" prop="startCityArr" style="padding-top:16px;">
                    <!-- <Button type="default" icon="android-apps">选择</Button> -->
                    <div>
                      <!-- <al-selector v-model="lineDetailForm.startCityArr" level="1" style="width:300px;display:inline-block;"/> -->
                      <al-cascader v-model="lineDetailForm.startCityArr" level="3" style="width:300px;display:inline-block;"/>
                    </div>
                  </Form-item>
                  <Form-item label="目的城市:" prop="endCityArr">
                    <!-- <Button type="default" icon="android-apps">选择</Button> -->
                    <al-cascader v-model="lineDetailForm.endCityArr" level="3" style="width:300px;display:inline-block;"/>
                  </Form-item>
                  <Form-item label="活动属性:" prop="linePropertity">
                    <Button icon="android-apps" @click="lineDetailPropertySelect">选择</Button>
                    <!-- <input v-model="lineDetailForm.linePropertity" /> -->
                  </Form-item>
                  <Form-item label="图标设置:" prop="tagWord">
                    <Button icon="android-apps" @click="lineDetailTagSelect">选择</Button>
                    <!-- <input v-model="lineDetailForm.tagWord" /> -->
                  </Form-item>
                  
                </TabPane>
                <TabPane label="促销策略">
                  <template>
                    <Form-item label="推荐次数:" prop="recommendNum" style="padding-top:16px;">
                      <Input type="text" v-model="lineDetailForm.recommendNum" clearable placeholder="请输入活动推荐次数" style="width: 400px"/>
                    </Form-item>
                    <Form-item label="满意度:" prop="satisfyScore">
                      <Input type="text" v-model="lineDetailForm.satisfyScore" clearable placeholder="请输入活动满意度" style="width: 400px"/>
                    </Form-item>
                    <Form-item label="销量:" prop="saleVolume">
                      <Input type="text" v-model="lineDetailForm.saleVolume" clearable placeholder="请输入活动销量" style="width: 400px"/>
                    </Form-item>
                  </template>
                </TabPane>
                <TabPane label="活动行程">
                  <template>
                    <Form-item label="排版方式:" style="padding-top:16px;">
                      <RadioGroup v-model="layoutWay" type="button">
                        <Radio label="0">标准版</Radio>
                        <Radio label="1">简洁版</Radio>
                    </RadioGroup>
                    </Form-item>
                    <Form-item label="行程附件:">
                      <Button icon="android-apps">上传附件</Button>
                    </Form-item>
                    <Form-item label="用餐情况:">
                      <RadioGroup>
                        <Radio label="0">显示</Radio>
                        <Radio label="1">隐藏</Radio>
                      </RadioGroup>
                    </Form-item>
                    <Form-item label="住宿情况:">
                      <RadioGroup>
                        <Radio label="0">显示</Radio>
                        <Radio label="1">隐藏</Radio>
                      </RadioGroup>
                    </Form-item>
                    <Form-item label="往返交通:">
                      <RadioGroup>
                        <Radio label="0">显示</Radio>
                        <Radio label="1">隐藏</Radio>
                      </RadioGroup>
                    </Form-item>
                    <hr style="border-bottom:1px solid #dddee1; height:1px;">
                    <div>
                      <div v-if="layoutWay==='0'">
                        <Form-item label="第一天:" style="padding-top:16px;">
                          <Input type="text" clearable style="width: 400px"/>
                        </Form-item>
                        <Form-item label="用餐情况:">
                          <RadioGroup>
                            <Radio label="0">早餐</Radio>
                            <Radio label="1">午餐</Radio>
                            <Radio label="2">晚餐</Radio>
                          </RadioGroup>
                        </Form-item>
                        <Form-item label="住宿情况:">
                          <Input type="text" clearable style="width: 200px"/>
                        </Form-item>
                        <Form-item label="交通工具:">
                          <RadioGroup>
                            <Radio label="0">汽车</Radio>
                            <Radio label="1">火车</Radio>
                            <Radio label="2">飞机</Radio>
                            <Radio label="2">轮船</Radio>
                          </RadioGroup>
                        </Form-item>
                        <Form-item label="活动行程" prop="lineContent">
                          <textarea type="text" v-model="lineDetailForm.lineContent" clearable placeholder="请输入活动行程" style="width:600px;height:200px;resize:none;line-height:2.0"/>
                        </Form-item>
                      </div>
                      <div v-else>
                        <Form-item label="活动行程" prop="lineContent">
                          <textarea type="text" v-model="lineDetailForm.lineContent" clearable placeholder="请输入活动行程" style="width:600px;height:200px;resize:none;line-height:2.0"/>
                        </Form-item>
                      </div>

                    </div>


                    
                  </template>
                </TabPane>
                <TabPane label="图片">
                  <template>
                    <div>
                      <div style="padding-top:20px;padding-left:20px;">封面图片</div>
                      <image-component 
                          ref="lineLitpicComp"
                          @on-remove-success="lineLitpicRemoveSuccess"
                          @on-add-success="lineLitpicAddSuccess">
                        </image-component>

                      <hr style="border-bottom:1px solid #dddee1; height:1px;">

                      <div style="padding-top:20px;padding-left:20px;">详情列表图片</div>
                      <image-component 
                          ref="linePiclistComp"
                          @on-remove-success="linePiclistRemoveSuccess"
                          @on-add-success="linePiclistAddSuccess">
                        </image-component>
                    </div>

                  </template>
                </TabPane>
                <TabPane label="报名须知">
                  <template>
                    <Form-item label="报名须知" prop="description" style="padding-top:16px;">
                      <textarea type="text" v-model="lineDetailForm.description" clearable placeholder="请输入报名须知" style="width:600px;height:200px;resize:none;line-height:2.0"/>
                    </Form-item>
                  </template>
                </TabPane>
                <TabPane label="费用说明">
                  <template>
                    <Form-item label="费用说明" prop="feeInclude" style="padding-top:16px;">
                      <textarea type="text" v-model="lineDetailForm.feeInclude" clearable placeholder="请输入费用说明" style="width:600px;height:200px;resize:none;line-height:2.0"/>
                    </Form-item>
                  </template>
                </TabPane>
                <TabPane label="注意事项">
                  <template>
                    <Form-item label="注意事项" prop="notice" style="padding-top:16px;">
                      <textarea type="text" v-model="lineDetailForm.notice" clearable placeholder="请输入注意事项" style="width:600px;height:200px;resize:none;line-height:2.0"/>
                    </Form-item>
                  </template>
                </TabPane>
                <!-- <TabPane label="报名字段">报名字段的内容</TabPane>
                <TabPane label="优化信息">优化信息的内容</TabPane>
                <TabPane label="扩展设置">扩展设置</TabPane> -->
            </Tabs>

            <hr style="border-bottom:1px solid #dddee1; height:1px;">
            <!-- <Form-item style="padding:16px 0px;">
              <Button type="info" style="width:100px;">保存</Button>
            </Form-item> -->
          </Form>
         
          <div style="padding:16px 0px;margin-left:2px;" class="operation">
            <Button @click="cancelSubmitLine" icon="android-arrow-back" style="width:120px;margin-right:10px;">返回主页</Button>
            <Button :loading="submitLoading" @click="submitLine" type="primary" :icon="lineActivityButtonTypeIcon" style="width:120px;">{{lineActivityButtonTypeText}}</Button>
          </div> 
         
      </template>

      <Modal :title="modalTitle" v-model="lineDetailPropetyModalVisible" :mask-closable='false' :width="500">
          <Form ref="lineDetailPropetyForm" :model="lineDetailPropetyForm" :label-width="90">
            <FormItem label="旅行方式:">
              <CheckboxGroup>  
                <Checkbox label="0">省心跟团游</Checkbox>
                <Checkbox label="1">快乐自助游</Checkbox>
                <Checkbox label="2">特色游</Checkbox>
              </CheckboxGroup>
            </FormItem>
            <FormItem label="交通选择:">
              <CheckboxGroup>  
                <Checkbox label="0">飞机团</Checkbox>
                <Checkbox label="1">汽车团</Checkbox>
              </CheckboxGroup>
            </FormItem>
            <FormItem label="节日特惠:">
              <CheckboxGroup>  
                <Checkbox label="0">元旦</Checkbox>
                <Checkbox label="1">春节</Checkbox>
                <Checkbox label="2">端午</Checkbox>
                <Checkbox label="3">五一</Checkbox>
                <Checkbox label="4">清明</Checkbox>
                <Checkbox label="5">中秋</Checkbox>
                <Checkbox label="6">国庆</Checkbox>
              </CheckboxGroup>
            </FormItem>
            <!-- <div style="border-bottom:1px solid #dddee1; margin:10px 0;"></div>    -->
          </Form>
          <div slot="footer">
              <Button type="text" @click="cancelLineReview">取消</Button>
              <Button type="primary" :loading="submitLoading" @click="submitLineReview">确定</Button>
          </div>
    </Modal>
    <Modal :title="modalTitle" v-model="lineDetailTagModalVisible" :mask-closable='false' :width="500">
          <div>
            <Tag type="border" color="yellow">HOT</Tag>
            <Tag type="border" color="yellow">跟团</Tag>
            <Tag type="border" color="yellow">自由行</Tag>
            <Tag type="border" color="yellow">活动</Tag>
            <Tag type="border" color="yellow">特价</Tag>
            <Tag type="border" color="yellow">新品</Tag>
            <Tag type="border" color="yellow">热销</Tag>
            <Tag type="border" color="yellow">促销</Tag>
            <Tag type="border" color="yellow">抢购</Tag>
            <Tag type="border" color="yellow">包车游</Tag>
            <Tag type="border" color="yellow">休闲游</Tag>
            <Tag type="border" color="yellow">观光游</Tag>
            <Tag type="border" color="yellow">自助游</Tag>

          </div>
          <div slot="footer">
              <Button type="text" @click="cancelLineReview">取消</Button>
              <Button type="primary" :loading="submitLoading" @click="submitLineReview">确定</Button>
          </div>
    </Modal>


    </div>
</template>

<script>

import dateFormatUtil from "@/utils/dateFormatUtil";
import tinymce from 'tinymce';
import ImageComponent from "./../comm-comp/imageComponent.vue";

export default {
  name: "line-activity-detail",
  components:{
    ImageComponent
  },
  data() {
    const validateMobile = (rule, value, callback) => {
      var reg = /^[1][3,4,5,7,8][0-9]{9}$/;
      if (!reg.test(value)) {
        callback(new Error("手机号格式错误"));
      } else {
        callback();
      }
    };
    const validateactivityNameNoBlank = (rule, value, callback) => {
      var validObj = rule.validObj;
      var reg = new RegExp(validObj.regexp);
      if (reg.test(value)) {
        callback(new Error(validObj.msg));
      } else {
        callback();
      }
    };
    return {
      buttonTypeText: "添加",
      single: false,
      loading: true,
      drop: false,
      dropDownContent: "展开",
      dropDownIcon: "chevron-down",
      selectCount: 0,
      selectList: [],
      lineDetailForm: {
        title: "",
        sellPoint: "",
        lineDay: "",
        lineNight: "",
        totalNum: "",
        storePrice: "",
        price: "",
        signStartDate: "",
        signEndDate: "",
        beginDate: "",
        endDate: "",
        lineDate: "",
        lineBefore: "",
        startCity: "",
        endCity: "",
        linePropertity: "",
        tagWord: "",
        recommendNum: "",
        satisfyScore: "",
        saleVolume: "",
        lineContent: "",
        description: "",
        feeInclude: "",
        notice: "",
        startCityArr: [],
        endCityArr: [],
        litpic: "",
        piclist:""
      },

      layoutWay: "0",
      // layoutWaySelected: ture,
      modalType: 0,
      activityModalVisible: false,

      lineActivityDetailModalType: 0,
      lineActivityButtonTypeText: "添加",
      lineActivityButtonTypeIcon: "plus-round",

      lineDetailPropetyModalVisible: false,
      lineDetailTagModalVisible: false,
      lineDetailPropetyForm:{

      },

      modalTitle: "",
     
      // lineDetailForm: {
      //   sex: 1,
      //   type: 0
      // },
      userRoles: [],
      roleList: [],
      errorPass: "",
      lineDetailFormValidate: {
        title: [
          { required: true, message: "活动标题不能为空", trigger: "blur" },
          { max: 64, message: '活动标题不能太长'},
          { validator: validateactivityNameNoBlank, validObj:{regexp:/\s+/g,msg:"活动标题不允许包含空格"} ,trigger: "blur"}
        ]
      },
      submitLoading: false,
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: "编号",
          key: "activityName",
          width: 120,
          sortable: true
        },
        {
          title: "名称",
          key: "activityName",
          width: 120,
          sortable: true
        },
        {
          title: "发起人",
          key: "activityName",
          width: 120,
          sortable: true
        },
        {
          title: "报价",
          key: "mobilePhone",
          width: 120,
          sortable: true
        },
        {
          title: "有效期",
          key: "email",
          width: 160,
          sortable: true
        },
        // {
        //   title: "产品状态",
        //   key: "sex",
        //   width: 160,
        //   align: "center",
        //   render: (h, params) => {
        //     let re = "";
        //     if (params.row.sex === 1) {
        //       re = "男";
        //     } else if (params.row.sex === 0) {
        //       re = "女";
        //     }
        //     return h("div", re);
        //   }
        // },
        {
          title: "状态",
          key: "status",
          align: "center",
          width: 150,
          render: (h, params) => {
            let re = "";
            if (params.row.status === 0) {
              return h("div", [
                h(
                  "Tag",
                  {
                    props: {
                      type: "dot",
                      color: "green"
                    }
                  },
                  "正常启用"
                )
              ]);
            } else if (params.row.status === -1) {
              return h("div", [
                h(
                  "Tag",
                  {
                    props: {
                      type: "dot",
                      color: "red"
                    }
                  },
                  "禁用"
                )
              ]);
            }
          },
          filters: [
            {
              label: "正常启用",
              value: 0
            },
            {
              label: "禁用",
              value: -1
            }
          ],
          filterMultiple: false,
          filterMethod(value, row) {
            if (value === 0) {
              return row.status === 0;
            } else if (value === -1) {
              return row.status === -1;
            }
          }
        },
        {
          title: "创建时间",
          key: "createTime",
          sortable: true,
          sortType: "desc",
          width: 150
        },
        {
          title: "操作",
          key: "action",
          width: 240,
          align: "center",
          render: (h, params) => {
            if (params.row.status === 0) {
              return h("div", [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.edit(params.row);
                      }
                    }
                  },
                  "编辑"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "ghost",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.disable(params.row);
                      }
                    }
                  },
                  "禁用"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "error",
                      size: "small"
                    },
                    on: {
                      click: () => {
                        this.remove(params.row);
                      }
                    }
                  },
                  "删除"
                )
              ]);
            } else {
              return h("div", [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.edit(params.row);
                      }
                    }
                  },
                  "编辑"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "success",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.enable(params.row);
                      }
                    }
                  },
                  "启用"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "error",
                      size: "small"
                    },
                    on: {
                      click: () => {
                        this.remove(params.row);
                      }
                    }
                  },
                  "删除"
                )
              ]);
            }
          }
        }
      ],
      data: [],
      exportData: [],
      total: 0

    };
  },
  methods: {
    init() {
      // this.getactivityList();
      // this.cleanSelectCount();
    },

    resetFormByType: function(type,updateLine){
      console.log(updateLine);
      if(0 === type){
        this.lineActivityDetailModalType = 0;
        this.lineActivityButtonTypeText = "添加";
        this.lineActivityButtonTypeIcon = "plus-round";

        this.$refs.lineLitpicComp.initByType("line",0,null);
        this.$refs.linePiclistComp.initByType("line",0,null);
      
      }else if(1 === type){
        this.lineActivityDetailModalType = 1;
        this.lineActivityButtonTypeText = "编辑";
        this.lineActivityButtonTypeIcon = "edit";
        this.lineDetailForm = updateLine;
        console.log(updateLine)

        this.$refs.lineLitpicComp.initByType("line",1,updateLine.litpic);
        this.$refs.linePiclistComp.initByType("line",1,updateLine.piclist);
        
      }else{}

      this.$refs.lineDetailForm.resetFields();
      for (let attr in this.lineDetailForm) {
        if (this.lineDetailForm[attr] == null) {
          this.lineDetailForm[attr] = "";
        }
      }
    },


    initCULineDetailForm() {
      this.$refs.lineDetailForm.resetFields();
      for (let attr in this.lineDetailForm) {
        if (this.lineDetailForm[attr] == null) {
          this.lineDetailForm[attr] = "";
        }
      }

      let transferControlObj = this.$router.currentRoute.params;
      if(transferControlObj){
        let modalType = transferControlObj.modalType;
        this.modalType = modalType;
        if (modalType === 1) { //获取数据回显
        this.buttonTypeText = "编辑";
          let _this = this;
          _this.loading = true; 
          this.getRequest("/line/getLineById/" + transferControlObj.id ).then(res =>{
            _this.loading = false;
            let editLine = res.result;
            _this.lineDetailForm = editLine;
            // let editSupplierProvCode = JSON.parse(editSupplier.province).code;
            // let editSupplierCityCode = JSON.parse(editSupplier.city).code;
            // _this.supplierForm.supplierFormAddressArr = [editSupplierProvCode, editSupplierCityCode], 
            // console.log( _this.supplierForm.supplierFormAddressArr);        
            // _this.supplierModalVisible = true;

          })
        }else{
          this.buttonTypeText = "添加";
        }
      }
    },

    lineDetailPropertySelect(){
      this.modalTitle = "属性设置";
      this.lineDetailPropetyModalVisible = true;
      
    },
    lineDetailTagSelect(){
      this.modalTitle = "图标设置";
      this.lineDetailTagModalVisible = true;
    },
    cancelLineReview() {
      this.lineDetailPropetyModalVisible = false;
    },
    submitLineReview() {
      
    },
    
    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getactivityList();
    },
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getactivityList();
    },
    selectDateRange(v) {
      if (v) {
        this.searchForm.startDate = v[0];
        this.searchForm.endDate = v[1];
      }
    },
    selectBirthdayDateRange(v) {
      if (v) {
        this.searchForm.startBirthday = v[0];
        this.searchForm.endBirthday = v[1];
      }
    },
    getactivityList() {
      this.loading = true;      
      this.getRequest("/line/list", this.searchForm).then(res => {  
        this.loading = false;
        if (res.success === true) {
          this.data = res.result.content;
          this.total = res.result.totalElements;
        }
      });
    },
    handleSearch() {
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.init();
    },
    handleReset() {
      this.$refs.searchForm.resetFields();
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      // 重新加载数据
      this.init();
    },
    changeSort(e) {
      this.searchForm.sort = e.key;
      this.searchForm.order = e.order;
      if (e.order === "normal") {
        this.searchForm.order = "";
      }
      this.init();
    },
    getRoleList() {
      this.getRequest("/role/getAllList").then(res => {
        if (res.success === true) {
          this.roleList = res.result;
        }
      });
    },
    handleDropdown(name) {
      if (name === "exportData") {
        if (this.selectCount <= 0) {
          this.$Message.warning("您还未选择要导出的数据");
          return;
        }
        this.$Modal.confirm({
          title: "确认导出",
          content: "您确认要导出所选 " + this.selectCount + " 条数据?",
          onOk: () => {
            this.$refs.exportTable.exportCsv({
              filename: "用户数据"
            });
          }
        });
      } else if (name === "refresh") {
        this.getactivityList();
      }
    },
    selectRoles(v) {},
    cancelactivity() {
      this.activityModalVisible = false;
    },
    submitLine() {
      this.$refs.lineDetailForm.validate(valid => {
        if (valid) {
          console.log("==============lineDetailForm===============");
          console.log(this.lineDetailForm);
          
          let url = "";
          if(this.lineDetailForm.lineDate){
            this.lineDetailForm.lineDate = dateFormatUtil.format(new Date(this.lineDetailForm.lineDate),"yyyy-MM-dd hh:mm:ss");
          }
          if(this.lineDetailForm.signStartDate){
            this.lineDetailForm.signStartDate = dateFormatUtil.format(new Date(this.lineDetailForm.signStartDate),"yyyy-MM-dd hh:mm:ss");
          }
          if(this.lineDetailForm.signEndDate){
            this.lineDetailForm.signEndDate = dateFormatUtil.format(new Date(this.lineDetailForm.signEndDate),"yyyy-MM-dd hh:mm:ss");
          }
          if(this.lineDetailForm.beginDate){
            this.lineDetailForm.beginDate = dateFormatUtil.format(new Date(this.lineDetailForm.beginDate),"yyyy-MM-dd hh:mm:ss");
          }
          if(this.lineDetailForm.endDate){
            this.lineDetailForm.endDate = dateFormatUtil.format(new Date(this.lineDetailForm.endDate),"yyyy-MM-dd hh:mm:ss");
          }
          if (this.modalType === 1) {
            // 编辑用户
            url = "/line/update";
            this.submitLoading = true;

            let updateLine = this.lineDetailForm;

            delete updateLine.bookCount;
            delete updateLine.isHidden;
            delete updateLine.isLineBefore;
            delete updateLine.seatLeft;
            delete updateLine.showNum;

            this.putRequest(url, updateLine).then(res => {
              this.submitLoading = false;
              if (res.success === true) {
                this.$Message.success("更新操作成功");

                this.$emit('on-line-activity-success',true);

                // this.$store.commit('clearCurrentTags', this);
                // this.$router.push({
                //     name: 'line-activity-manage'
                // });
                // this.init();
                // this.activityModalVisible = false;
              }
            });
          }else{
            url = "/line/create";
            this.submitLoading = true;
            let createLine = this.lineDetailForm;
            createLine.flag = "1";
            console.log("=============createLine===========");
            console.log(createLine);
            this.postRequest(url, createLine).then(res => {
              this.submitLoading = false;
              if (res.success === true) {
                this.$Message.success("操作成功");

                this.$emit('on-line-activity-success',true);

                //关闭当前添加界面 跳转到线路界面 刷新数据
                // this.$store.commit('clearCurrentTags', this);
                // this.$router.push({
                //     name: 'line-activity-manage'
                // });

                // this.init();
                // this.activityModalVisible = false;
              }
            });
          }

        }
      });
    },
    cancelSubmitLine:function(){
      this.$emit('on-line-activity-cancel',true);
    },

    addactivity(v) {
      this.modalType = 0;
      this.modalTitle = "添加会员";
      this.$refs.lineDetailForm.resetFields();
      for (let attr in this.lineDetailForm) {
        if (this.lineDetailForm[attr] == null) {
          this.lineDetailForm[attr] = "";
        }
      }
      this.activityModalVisible = true;
    },
    edit(v) {
      this.modalType = 1;
      this.modalTitle = "编辑会员";
      this.$refs.lineDetailForm.resetFields();
      // 转换null为""
      for (let attr in v) {
        if (v[attr] === null) {
          v[attr] = "";
        }
      }
      let str = JSON.stringify(v);
      let userInfo = JSON.parse(str);
      this.lineDetailForm = userInfo;
      // let selectRolesId = [];
      // this.lineDetailForm.roles.forEach(function(e) {
      //   selectRolesId.push(e.id);
      // });
      // this.lineDetailForm.roles = selectRolesId;
      this.activityModalVisible = true;
    },
    enable(v) {
      this.$Modal.confirm({
        title: "确认启用",
        content: "您确认要启用用户 " + v.activityName + " ?",
        onOk: () => {
          this.postRequest("/activity/enable/" + v.id).then(res => {
            if (res.success === true) {
              this.$Message.success("操作成功");
              this.init();
            }
          });
        }
      });
    },
    disable(v) {
      this.$Modal.confirm({
        title: "确认禁用",
        content: "您确认要禁用用户 " + v.activityName + " ?",
        onOk: () => {
          this.postRequest("/activity/disable/" + v.id).then(res => {
            if (res.success === true) {
              this.$Message.success("操作成功");
              this.init();
            }
          });
        }
      });
    },
    remove(v) {
      this.$Modal.confirm({
        title: "确认删除",
        content: "您确认要删除用户 " + v.activityName + " ?",
        onOk: () => {
          this.deleteRequest("/activity/delete/" + v.id).then(res => {
            if (res.success === true) {
              this.$Message.success("删除成功");
              this.init();
            }
          });
        }
      });
    },
    dropDown() {
      if (this.drop) {
        this.dropDownContent = "展开";
        this.dropDownIcon = "chevron-down";
      } else {
        this.dropDownContent = "收起";
        this.dropDownIcon = "chevron-up";
      }
      this.drop = !this.drop;
    },
    showSelect(e) {
      this.exportData = e;
      this.selectList = e;
      this.selectCount = e.length;
    },
    clearSelectAll() {
      this.$refs.table.selectAll(false);
      this.cleanSelectCount();
    },
    cleanSelectCount(){
      this.selectCount = 0;
    },
    delAll() {
      if (this.selectCount <= 0) {
        this.$Message.warning("您还未选择要删除的数据");
        return;
      }
      this.$Modal.confirm({
        title: "确认删除",
        content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
        onOk: () => {
          let ids = "";
          this.selectList.forEach(function(e) {
            ids += e.id + ",";
          });
          ids = ids.substring(0, ids.length - 1);
          this.deleteRequest("/activity/delete/" + ids).then(res => {
            if (res.success === true) {
              this.$Message.success("删除成功");
              this.init();
            }
          });
        }
      });
    }


    //picture methods start
    ,
    lineLitpicRemoveSuccess:function(res){
      console.log('==lineLitpicRemoveSuccess==');
      console.log(res);
      if(res.flag){
        this.lineDetailForm.litpic = res.pathStr;
      }
    },
    lineLitpicAddSuccess:function(res){
      console.log('==lineLitpicAddSuccess==');
      console.log(res);
      if(res.flag){
        this.lineDetailForm.litpic = res.pathStr;
      }
    },
    linePiclistRemoveSuccess:function(res){
      console.log('==linePiclistRemoveSuccess==');
      console.log(res);
      if(res.flag){
        this.lineDetailForm.piclist = res.pathStr;
      }
    },
    linePiclistAddSuccess:function(res){
      console.log('==linePiclistAddSuccess==');
      console.log(res);
      if(res.flag){
        this.lineDetailForm.piclist = res.pathStr;
      }
    }
     //picture methods end


  },
  mounted() {
    this.init();
    this.initCULineDetailForm();
  }
};
</script>